const { resolve } = require('path')

const Router = require('koa-router')
const router = new Router()

const { MANAGE_BASEROUTER } = require(resolve(__dirname, '../config/default'))

const { verifyToken } = require(resolve(__dirname, '../middleware/index'))

const {
  addArticle,
  getArticle,
  findArticle,
  delArticle,
  upArticle,
  releaseArticle,
  getArticleTotal,
  getArticleOne,
  lookArticle,
  discussArticle,
  findArticleOne
} = require(resolve(__dirname, '../routerHandle/managementHandle/article'))


// 查询文章 /api/manage
router.get(MANAGE_BASEROUTER + '/article/find', getArticle)

// 添加文章
router.post(MANAGE_BASEROUTER + '/article/add', verifyToken, addArticle)

// 修改文章
router.post(MANAGE_BASEROUTER + '/article/update', verifyToken, upArticle)

// 搜索文章
router.post(MANAGE_BASEROUTER + '/article/search', verifyToken, findArticle)

// 搜索一种文章
router.get(MANAGE_BASEROUTER + '/article/search/one', verifyToken, findArticleOne)

// 搜索文章one
router.post(MANAGE_BASEROUTER + '/article/gain', verifyToken, getArticleOne)

// 删除文章
router.post(MANAGE_BASEROUTER + '/article/del', verifyToken, delArticle)

// 发布文章
router.post(MANAGE_BASEROUTER + '/article/release', verifyToken, releaseArticle)

// 获取文章总数
router.get(MANAGE_BASEROUTER + '/article/total', getArticleTotal)

// 查看文章数
router.post(MANAGE_BASEROUTER + '/article/look', lookArticle)

// 点赞文章数
router.post(MANAGE_BASEROUTER + '/article/discuss', discussArticle)


module.exports = router